//
//  DetailModel.m
//  LvXingPai
//
//  Created by mafang on 16/8/11.
//  Copyright © 2016年 _Junxee. All rights reserved.
//

#import "DetailModel.h"

@implementation DetailModel

// 初始化赋值
- (instancetype)initWithDict:(NSDictionary *)dict
{
    if (self = [super init]) {
        
        self.commodityId = [NSString stringWithFormat:@"%@",dict[@"commodityId"]];
        self.title = dict[@"title"];
        self.rating = [NSString stringWithFormat:@"%@",dict[@"rating"]];
        self.salesVolume = [NSString stringWithFormat:@"%@",dict[@"salesVolume"]];
        self.marketPrice = [NSString stringWithFormat:@"%@",dict[@"marketPrice"]];
        self.price = [NSString stringWithFormat:@"%@",dict[@"price"]];
        
        NSDictionary *dic = dict[@"cover"];
        self.coverImage = dic[@"url"];
        
        NSDictionary *d = dict[@"seller"];
        self.name = d[@"name"];
        
        NSArray *arr = d[@"lang"];
        if (arr.count) {
            self.lang = arr[0];
        } else {
            self.lang = nil;
        }
        
        NSDictionary *dd = dict[@"country"];
        self.country = dd[@"zhName"];
        
        NSDictionary *ddd = dict[@"locality"];
        self.locality = ddd[@"zhName"];
        
        self.timeCost = dict[@"timeCost"];
        
        NSDictionary *d2 = dict[@"desc"];
        self.desc = d2[@"summary"];
        
        NSArray *arr2 = dict[@"notice"];
        NSDictionary *d3 = arr2[0];
        self.costContain = d3[@"summary"];
        
        NSArray *arr3 = dict[@"refundPolicy"];
        NSDictionary *d4 = arr3[0];
        self.reserve = d4[@"summary"];
        
        NSDictionary *d5 = arr3[1];
        self.refund = d5[@"summary"];
        
        NSArray *arr4 = dict[@"trafficInfo"];
        NSDictionary *d6 = arr4[0];
        self.trafficSummary = d6[@"summary"];
        
        self.descUrl = dict[@"http://h5.lvxingpai.com/poi/item.php?pid=103286&field=desc"];
        self.noticeUrl = dict[@"http://h5.lvxingpai.com/poi/item.php?pid=103286&field=notice"];
        self.refundUrl = dict[@"http://h5.lvxingpai.com/poi/item.php?pid=103286&field=refundPolicy"];
        self.trafficUrl = dict[@"http://h5.lvxingpai.com/poi/item.php?pid=103286&field=trafficInfo"];
        
        self.comments = [NSString stringWithFormat:@"%@",dict[@"commentCnt"]];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end
